package concurrency.chapter3;

/**
 * @author 夏焰波
 * @date 2020-06-04 1:23
 */
public class CreateThread5 {
    private static int counter = 1;

    public static void main(String[] args) {
        for (int i = 0; i < Integer.MAX_VALUE; i++) {
            counter++;
            /*new Thread(new Runnable() {
                @Override
                public void run() {
                    byte[] data = new byte[1024 * 1024 * 2];
                    while (true) {
                        try {
                            Thread.sleep(1);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
            }).start();*/
            new Thread(() -> {
                byte[] data = new byte[1024 * 1024 * 2];
                while (true) {
                    /*try {
                        Thread.sleep(1);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }*/
                }
            }).start();
        }
        System.out.println(counter);
    }
}
